home *** CD-ROM | disk | FTP | other *** search
- #include "lib.h"
-
- #ifndef __MSHORT__
- asm(".text; .even; .globl _write; _write:"); /* dept of dirty tricks */
- #endif
- PUBLIC long lwrite(fd, buffer, nbytes)
- int fd;
- _CONST _VOIDSTAR buffer;
- long nbytes;
- {
- long tot, left;
- int n;
-
- if(nbytes <= 32767)
- {
- return (long)callm1(FS, WRITE, fd, (int)nbytes, 0, buffer, NIL_PTR, NIL_PTR);
- }
- for( tot = 0, left = nbytes; left > 0; )
- {
- n = (left > 32767) ? 32767 : (int)left;
- if((n = callm1(FS, WRITE, fd, n, 0, buffer, NIL_PTR, NIL_PTR)) < 0)
- return((long)n);
- if(n == 0) return(tot);
- tot += n;
- left -= n;
- (char *)buffer += n;
- }
- return(tot);
- }
-
- #ifdef __MSHORT__
- PUBLIC int write(fd, buffer, nbytes)
- int fd;
- _CONST _VOIDSTAR buffer;
- int nbytes;
- {
- return (int)lwrite(fd, buffer, (long)nbytes);
- }
- #endif
-